import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 物联网卡信息
 */
@Entity('iot_card')
export class IotCardCardEntity extends BaseEntity {
  @Index({ unique: true })
  @Column({ comment: 'ICCID' })
  iccid: string;

  @Column({ comment: '激活日期', type: 'date', nullable: true })
  activateDate: Date;

  @Column({ comment: '到期日期', type: 'date', nullable: true })
  expireDate: Date;

  @Column({ comment: '状态', dict: ['正常', '停用'], default: 0 })
  status: number;

  @Column({
    comment: '本月总流量（MB）',
    type: 'decimal',
    precision: 10,
    scale: 2,
    nullable: true,
  })
  totalTrafficMonth: number;

  @Column({
    comment: '本月使用流量（MB）',
    type: 'decimal',
    precision: 10,
    scale: 2,
    nullable: true,
  })
  usedTrafficMonth: number;

  @Column({
    comment: '剩余流量（MB）',
    type: 'decimal',
    precision: 10,
    scale: 2,
    nullable: true,
  })
  remainingTraffic: number;

  @Column({ comment: '短信已用数', nullable: true })
  smsUsedCount: number;

  @Index({ unique: true })
  @Column({ comment: '所属设备ID' })
  deviceId: number;
}
